package com.qf.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.qf.mapper.DtsGrouponRulesMapper;
import com.qf.pojo.DtsGrouponRules;
import com.qf.service.DtsGrouponRulesService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

/**
 * @version 1.0
 * @auther Administrator
 * @date 2023/2/25 9:38
 */
@Service
public class DtsGrouponRulesServiceImpl implements DtsGrouponRulesService {

    @Autowired
    private DtsGrouponRulesMapper dtsGrouponRulesMapper;

    @Override
    public IPage<DtsGrouponRules> findListByQuery(String goodsId, String sort, String order, Integer page, Integer limit) {
        return dtsGrouponRulesMapper.selectPage(new Page<DtsGrouponRules>(page,limit)
                ,new QueryWrapper<DtsGrouponRules>()
                        .eq(!StringUtils.isEmpty(goodsId),"goods_id",goodsId)
                        .orderBy(!StringUtils.isEmpty(sort),"ASC".equalsIgnoreCase(order),sort)
        );
    }
    /**
     * 添加
     * @param dtsGrouponRules
     * @return
     */
    @Override
    public DtsGrouponRules create(DtsGrouponRules dtsGrouponRules) {
        dtsGrouponRulesMapper.insert(dtsGrouponRules);
        return dtsGrouponRules;
    }
}
